﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Administration/Administration.Master" CodeBehind="Laboratoare.aspx.cs" Inherits="IEWebSite.Administration.Laboratoare" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .MyImageButton
        {
            cursor: hand;
        }
        .EditFormHeader td
        {
            font-size: 14px;
            padding: 4px !important;
            color: Green;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <h1> Laboratoare </h1>
        <telerik:RadGrid ID="RadGrid1" DataSourceID="SessionDataSource1" runat="server" ShowStatusBar="true"
            AutoGenerateColumns="False" PageSize="3" AllowSorting="True" AllowMultiRowSelection="False"
            AllowPaging="True" GridLines="None" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
            AllowAutomaticUpdates="True" OnItemUpdated="RadGrid1_ItemUpdated" OnItemDeleted="RadGrid1_ItemDeleted"
            OnItemInserted="RadGrid1_ItemInserted" OnInsertCommand="RadGrid1_InsertCommand">
            <PagerStyle Mode="NumericPages"></PagerStyle>
            <MasterTableView DataSourceID="SessionDataSource1" DataKeyNames="IdLaborator" AllowMultiColumnSorting="True"
                Width="100%" CommandItemDisplay="Top" Name="Laboratoare">
                <DetailTables>
                    <telerik:GridTableView DataKeyNames="IdSoftware, IdLaborator" DataSourceID="SessionDataSource2" Width="100%"
                        runat="server" CommandItemDisplay="Top" Name="Software">
                        <ParentTableRelation>
                            <telerik:GridRelationFields DetailKeyField="IdLaborator" MasterKeyField="IdLaborator" />
                        </ParentTableRelation>
                        <Columns>
                            <telerik:GridBoundColumn DataField="IdLaborator" UniqueName="IdLaborator" Visible="false" ReadOnly="true" ></telerik:GridBoundColumn>
                            <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn2">
                                <HeaderStyle Width="20px" />
                                <ItemStyle CssClass="MyImageButton" />
                            </telerik:GridEditCommandColumn>
                            <telerik:GridDropDownColumn  DataField="IdSoftware" DataSourceID="SoftwareSqlGetTitlu"
                             HeaderText="Software" ListTextField="SoftwareTitle" ListValueField="IdSoftware"
                             UniqueName="IdSoftware">
                            </telerik:GridDropDownColumn>
                            <telerik:GridButtonColumn ConfirmText="Delete these details record?" ButtonType="ImageButton"
                                CommandName="Delete" Text="Delete" UniqueName="DeleteColumn2">
                                <HeaderStyle Width="20px" />
                                <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                            </telerik:GridButtonColumn>
                        </Columns>
                        <SortExpressions>
                            <telerik:GridSortExpression FieldName="SoftwareTitle"></telerik:GridSortExpression>
                        </SortExpressions>
                    </telerik:GridTableView>
                </DetailTables>
                <Columns>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                        <HeaderStyle Width="20px" />
                        <ItemStyle CssClass="MyImageButton" />
                    </telerik:GridEditCommandColumn>
                    <telerik:GridBoundColumn SortExpression="IdLaborator" HeaderText="IdLaborator" HeaderButtonType="TextButton"
                        DataField="IdLaborator" UniqueName="IdLaborator" ReadOnly="true">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="Sala" HeaderText="Cod sala" HeaderButtonType="TextButton"
                        DataField="Sala" UniqueName="Sala">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="NrCalc" HeaderText="Nr Calculatoare" HeaderButtonType="TextButton"
                        DataField="NrCalc" UniqueName="NrCalc">
                    </telerik:GridBoundColumn>
                    <telerik:GridButtonColumn ConfirmText="Delete this customer?" ButtonType="ImageButton"
                        CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
                        <HeaderStyle Width="20px" />
                        <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                    </telerik:GridButtonColumn>
                </Columns>
                <SortExpressions>
                    <telerik:GridSortExpression FieldName="Sala"></telerik:GridSortExpression>
                </SortExpressions>
            </MasterTableView>
        </telerik:RadGrid>
       <asp:SqlDataSource ID="SessionDataSource1" ConnectionString="<%$ ConnectionStrings:SiteIEConnectionString %>"
            ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM Laborator"
            runat="server" DeleteCommand="DELETE FROM [Laborator] WHERE [IDLaborator] = @IDLaborator"
            InsertCommand="INSERT INTO Laborator(Sala, NrCalc) VALUES (@Sala, @NrCalc)"
            UpdateCommand="UPDATE [Laborator] SET [Sala] = @Sala, [NrCalc] = @NrCalc WHERE [IDLaborator] = @IDLaborator">
            <DeleteParameters>
                <asp:Parameter Name="original_IDLaborator" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="IDLaborator" Type="Int32" />
                <asp:Parameter Name="Sala" Type="String" />
                <asp:Parameter Name="NrCalc" Type="Int32" />
   
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="Sala" Type="String" />
                <asp:Parameter Name="NrCalc" Type="Int32" />
            </InsertParameters>
        </asp:SqlDataSource>
       <asp:SqlDataSource ID="SessionDataSource2" ConnectionString="<%$ ConnectionStrings:SiteIEConnectionString %>"
            OldValuesParameterFormatString="original_{0}" 
            runat="server" ProviderName="System.Data.SqlClient" 
            SelectCommand="SELECT * FROM SysSoftware inner join LaboratorXSoftware on SysSoftware.IdSoftware=LaboratorXSoftware.IdSoftware where LaboratorXSoftware.IdLaborator=@IdLaborator"
            DeleteCommand="DELETE FROM [LaboratorXSoftware] WHERE [IdLaborator] = @original_IdLaborator and [IdSoftware]=@original_IdSoftware " 
            InsertCommand="INSERT INTO LaboratorXSoftware(IdLaborator, IdSoftware) VALUES (@IdLaborator, @IdSoftware)"
            UpdateCommand="UPDATE [LaboratorXSoftware] SET [IdSoftware] =@IdSoftware WHERE [IdLaborator] = @original_IdLaborator AND [IdSoftware] = @original_IdSoftware">
            <SelectParameters>
                <asp:Parameter Name="IdLaborator" Type="Int32" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="original_IdLaborator" Type="Int32" />
                <asp:Parameter Name="original_IdSoftware" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="IdLaborator" Type="Int32" />
                <asp:Parameter Name="original_IdLaborator" Type="Int32" />
                <asp:Parameter Name="IdSoftware" Type="Int32" />
                <asp:Parameter Name="original_IdSoftware" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="IdLaborator" Type="Int32" />
                <asp:Parameter Name="IdSoftware" Type="Int32" />
            </InsertParameters>
     </asp:SqlDataSource>
         <asp:SqlDataSource ID="SoftwareSqlGetTitlu" runat="server" ConnectionString="<%$ ConnectionStrings:SiteIEConnectionString %>"
        SelectCommand="SELECT [SoftwareTitle], [IdSoftware] FROM [SysSoftware] ORDER BY [SoftwareTitle]">
    </asp:SqlDataSource>
        <br />
        <!-- content end -->
</asp:Content>
